﻿
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Windows.Forms;
using GDFlacTool.Common;

namespace GDFlacTool.Forms
{
    public partial class FormViewImage : Form
    {
        private readonly string _currentPath;


        public FormViewImage(string currentPath)
        {
            InitializeComponent();

            _currentPath = currentPath;
        }

        private void FormViewImage_Load(object sender, System.EventArgs e)
        {
            string folderImagePath = Path.Combine(_currentPath, "folder.jpg");

            if (File.Exists(folderImagePath))
            {
                picImageView.Image = Image.FromFile(folderImagePath);

                Text = string.Format("Image Viewer [{0}, {1}]", picImageView.Image.Size, Functions.GetFolderArtSizeFromFile(folderImagePath));
            }
            else
            {
                picImageView.Image = null;
                Text = string.Format("Image Viewer [No folder art]");
            }
        }

        private void FormViewImage_FormClosing(object sender, FormClosingEventArgs e)
        {
            if(picImageView.Image != null)
                picImageView.Image.Dispose();
        }
    }
}
